<?php require_once(dirname(__FILE__)."/../config/config.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php  
if($_SESSION['admin_name']=="")
{

	echo "<script>location.href='admin_login.php';</script>";
}
?>
 <?php
     switch($_GET["action"]){
	 	case "add":
$sql_2="select * from zy_gift where gift_name = '".$_POST['gift_name']."'";
$sql_3="select * from zy_user where username='".$_POST['username']."'";
$result_2=mysql_query($sql_2);
$result_3=mysql_query($sql_3);
while($zy_gift=mysql_fetch_array($result_2)){
while($zy_user=mysql_fetch_array($result_3)){
	$sql="INSERT INTO zy_gift_delivery ( gift_id,user_id,gift_status,Conversiontime,Deliverytime)
VALUES
('$zy_gift[gift_id]','$zy_user[user_id]','$_POST[gift_status]','$_POST[Conversiontime]','$_POST[Deliverytime]')  ";
}}
// echo $sql2,$sql3,$sql;


mysql_query($sql);

$id=mysql_insert_id($myconn);

if($id>0)
{
echo "<h3>礼品配送信息发布成功!</h3>";
}else
{ echo "<h3>礼品配送信息发布失败!</h3>";}
echo "<a href='gift_delivery.php'>浏览礼品配送信息</a>  ";
 
  echo "<a href='gift_delivery_add.php'>返回</a>&nbsp;&nbsp;";
 		break;
		case  "del":
		   $id = $_GET['id'];
	$sql = "delete from zy_gift_delivery where id = '".$id."'";
	mysql_query($sql);
	echo "<script>location.href='gift_delivery.php';</script>";
		break;

}
?>
</body>
</html>